{template common/contentheader}
<div class="setcontent" style="margin-bottom: 40px;">
	<div class="settitle">
		<h3>{lang admin_content_items:admin}</h3>
	</div>
	<div class="alert alert-info mt10">
		<span class="label label-info">{lang info:admin}</span>
		{lang admin_content_items:admin}
	</div>
	<div class="setform">
		<div class="alert">
			<form action="{url admin/contentshare}" method="post">
			<div class="input-append">
				Keyword:<input class="span2" type="text" name="keyword" id="keyword" value="$keyword" placeholder="keyword">
				<select id="catid" name="catid" class="span2">
					<option value="0" {echo ($catid==0)?'selected':''}>ALL</option>
					{loop $rootCategories $category}
					<option value="$category['category_id']" {echo ($catid==$category['category_id'])?'selected':''}>$category['category_name_cn']</option>
					{/loop}
				</select>
				<select id="is_show" name="is_show" class="span2">
					<option value="0" {echo ($is_show==0)?'selected':''}>{lang notverify:admin}</option>
					<option value="1" {echo ($is_show==1)?'selected':''}>{lang alreadyverify:admin}</option>
				</select>
				<button type="submit" class="btn btn-primary submit-btn">{lang search}</button>
			</div>
			</form>
		</div>
	</div>
	<div class="setform">
		<table class="table table-striped">
        <thead>
          <tr>
            <th width="20"><input type="checkbox" class="select_all" /></th>
            <th width="50">{lang items_pic:admin}</th>
            <th width="400">{lang items_title:admin}</th>
            <th width="80">{lang items_auther:admin}</th>
            <th width="80">{lang items_cat:admin}</th>
            <th width="100">{lang items_static:admin}</th>
            <th width="50">{lang items_type:admin}</th>
            <th width="50">{lang status:admin}</th>
            <th width="80">{lang operation:admin}</th>
          </tr>  
        </thead>
        <tbody>
        {loop $shares $share}
			<tr>
			<td><input type="checkbox" value="{$share['share_id']}" class="checkitem"></td>
			<td>{if $share['isarticle']}<span class="label label-warning">{lang article}</span>{else}<div class="img_border"><img width="32" data-bimg="{$share['image0']}" class="J_preview" src="{$share['square']}"></div>{/if}</td>
			<td><a href="{url detail/index?shareid=$share['share_id']}" target="_blank">$share['title']</a></td>
			<td><a href="{url home/user?uid=$share['user_id']}" target="_blank">$share['user_nickname']</a></td>
			<td align="center">$share['category_name_cn']</td>
            <td align="center">{$share['total_click']}/$share['total_comment']/$share['total_like']</td>
            <td align="center">{if $share['isarticle']}<span class="label label-warning">{lang article}</span>{elseif $share['isvideo']}<span class="label label-important">{lang video}</span>{else}<span class="label label-info">{lang image}</span>{/if}</td>
            <td align="center">{if $share['is_show']}<span class="label label-warning">{lang alreadyverify:admin}</span>{else}<span class="label label-warning">{lang notverify:admin}</span>{/if}</td>
            <td><a href="{url share/editshare?sid=$share['share_id']}" target="_blank">{lang edit:admin}</a> 
			<a href="{url admin/contentshare?act=delete&id=$share['share_id']}">{lang delete:admin}</a></td>
            </tr>
		{/loop}
        </tbody>
		</table>
	</div>
</div>
<div class="alert alert-info" style="position: fixed; bottom: 0px;left: 0px;right: 0px;margin-bottom: 0px;">
	<div class="pull-left"><label class="select_all mr10"><input type="checkbox" class="select_all" />{lang selectall:admin}</label>
		</div>
	<button class="btn btn-primary pull-left mr10"  data-msg="{lang verify_confirm:admin}" data-name="ids" data-uri="$verurl" data-acttype="ajax" data-tdtype="batch_action">{lang verify:admin}</button>
	<button class="btn btn-primary pull-left"  data-msg="{lang delete_confirm:admin}" data-name="ids" data-uri="$delurl" data-acttype="ajax" data-tdtype="batch_action">{lang delete:admin}</button>
    <div class="text_c pull-right">$pages</div>
</div>
<script type="text/javascript">
;(function($){
	$.fn.preview = function(){
		var w = $(window).width();
		var h = $(window).height();
		
		$(this).each(function(){
			$(this).hover(function(e){
				if(/.png$|.gif$|.jpg$|.bmp$|.jpeg$/.test($(this).attr("data-bimg"))){
					$("body").append("<div id='preview'><img src='"+$(this).attr('data-bimg')+"' /></div>");
				}
				var show_x = $(this).offset().left + $(this).width();
				var show_y = $(this).offset().top;
				var scroll_y = $(window).scrollTop();
				$("#preview").css({
					position:"absolute",
					padding:"4px",
					border:"1px solid #DDD",
					backgroundColor:"#f6f6f6",
					top:show_y + "px",
					left:show_x + "px",
					zIndex:1000
				});
				$("#preview > div").css({
					padding:"5px",
					backgroundColor:"white",
					border:"1px solid #cccccc"
				});
				if (show_y + 230 > h + scroll_y) {
					$("#preview").css("bottom", h - show_y - $(this).height() + "px").css("top", "auto");
				} else {
					$("#preview").css("top", show_y + "px").css("bottom", "auto");
				}
				$("#preview").fadeIn("fast")
			},function(){
				$("#preview").remove();
			})					  
		});
	};
})(jQuery);
(function($) {
	$.fn.listTable = function(options) {
		var self = this,
			local_url = window.location.search,
			settings = {
				url: $(self).attr('data-acturi')
			}
		if(options) {
			$.extend(settings, options);
		}
		$('.select_all').live('click', function(){
			$(':checkbox').attr('checked', this.checked);
		});
		$('button[data-tdtype="batch_action"]').live('click', function() {
			var btn = this;
			if($('.checkitem:checked').length == 0){
                alert('{lang no_selection:admin}');
				return false;
            }
			var ids = '';
			$('.checkitem:checked').each(function(){
				ids += $(this).val() + ',';
			});
			ids = ids.substr(0, (ids.length - 1));
			var uri = $(btn).attr('data-uri'),
				msg = $(btn).attr('data-msg'),
				idatt = $(btn).attr('data-name');
				acttype = $(btn).attr('data-acttype');
			if(msg != undefined){
				if(confirm(msg)){
					action();
				}
			}else{
				action();
			}
			function action(){
				$.ajax({
					type: "get",
					dataType: 'json',
					data: {'ids':ids},
					url: uri
				}).error(function() {
					alert('Operation faild!');
				}).success(function(result) {
					if (result.success === !0) {
						window.location = result.data.url;
					} else {
						alert(result.data.message);
					}
				});
			}
		});
	};
})(jQuery);
$(document).ready(function($) {
	var interval;
	$('#publish_form').validate({
		submitHandler: function(form) {
			var num_iid_str = '';
			$(':checkbox').each(function() {
				var checked = $(this).attr("checked");
				var num_iid = $(this).val();
				if(checked=='checked'){
					num_iid_str += num_iid+',';
				}
	        });
			if(num_iid_str==null||num_iid_str==""){
				alert("您没有内容需要发布，请选择。");
				return false;
			}
	        $("#num_iid_str").val(num_iid_str);
			$('#publish_form').ajaxSubmit({
					url:  $('#publish_form').attr('action'),
					type: 'POST',
					dataType: 'json',
					beforeSubmit: function(){
					    $("#ajax_message").html("发布中，多图采集过程可能稍慢，请耐心等候....");
					    interval = window.setInterval(function(){
							var text = $("#ajax_message").html();
							if (text.length < 55){
								$("#ajax_message").html(text + '.');					
							} else {
								 $("#ajax_message").html("发布中，多图采集过程可能稍慢，请耐心等候....");		
							}
						}, 200);
					},
					success: function(result) {
						 window.clearInterval(interval);
						 if (result.success === !0) {
							 $("#ajax_message").html("恭喜你，发布成功");
						 }else {
							 $("#ajax_message").html("发布失败....");
						 }
					}
			});
			return false;
		}
	});
	$('.J_preview').preview(); 
	$('.table').listTable();
});
</script>
{template common/contentfooter}